package timmytest;
import search.*;

import java.util.*;
/**
 * 
 * 
 * @author Rudi Lutz 
 * 
 */
public class CityMap extends UndirectedGraph<City,Road>
{
    private HashMap<City,ArrayList<Road>> roadsFrom;
    
    public CityMap()
    {
        roadsFrom = new HashMap<City,ArrayList<Road>>();
    }
    
    public List<Road> getEdges(City c)
    {
        if (!roadsFrom.containsKey(c)) {
            roadsFrom.put(c, new ArrayList<Road>());
        }
        return roadsFrom.get(c);
    }
    
    public void associateEdgeWithNode(Road road, City city)
    {
        if (!roadsFrom.containsKey(city)) {
            roadsFrom.put(city, new ArrayList<Road>());
        }
        ArrayList<Road> roads = roadsFrom.get(city);
        if (!roads.contains(road)) {
            roads.add(road);
        }
    }
 
}
